/*
 * Created by SharpDevelop.
 * Author: Joey
 * Date: 27/09/2007
 * Time: 01:39
 * 
 * Source is copyright Joey Sabey 2007
 */

using System;
using System.IO;
using System.Drawing;
using System.Windows.Forms;

namespace MonoTheism
{
	/// <summary>
	/// Description of AutoBuild_Properties.
	/// </summary>
	public partial class AutoBuild_Properties : Form
	{
		private bool bAcceptChanges = false;
		public bool AcceptChanges
		{
			get{return bAcceptChanges;}
		}
		public string Path
		{
			get{return txtOutputFolder.Text;}
		}
		
		public AutoBuild_Properties()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
		}
		public AutoBuild_Properties(string directory)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			this.txtOutputFolder.Text = directory;
		}
		
		void BtBrowseClick(object sender, EventArgs e)
		{
			FolderBrowserDialog fbdBrowse = new FolderBrowserDialog();
			fbdBrowse.Description = "Select a folder to autobuild "+
									"agent files to...";
			fbdBrowse.SelectedPath = txtOutputFolder.Text;
			if(fbdBrowse.ShowDialog() == DialogResult.OK)
			{
				txtOutputFolder.Text = fbdBrowse.SelectedPath;
			}
		}
		
		void BtCancelClick(object sender, EventArgs e)
		{
			Close();
		}
		
		void BtOkClick(object sender, EventArgs e)
		{
			try
			{
				if(!Directory.Exists(txtOutputFolder.Text))
					throw new Warning("Directory does not exist");
				bAcceptChanges = true;
				Close();
			}
			catch(Warning warn)
			{
				warn.Show();
			}
		}
	}
}
